wifi.setmode(wifi.STATION)
wifi.sta.config({ssid="@PHICOMM_D",pwd="123321000"})

t = tmr.create()
t:register(1000,tmr.ALARM_AUTO,function()
     if wifi.sta.getip() == nil then
            print("connecting...")
     else 
            print("connected,Ip is "..wifi.sta.getip()) 
            t:stop()
            udpSocket = net.createUDPSocket()
            udpSocket:listen(6000)
            port, ip = udpSocket:getaddr()
            print(string.format("local UDP socket address / port: %s:%d", ip, port))   
             udpSocket:on("receive", function(s, data, port, ip)
    print(string.format("received '%s' from %s:%d", data, ip, port))
end)
           udpSocket:send("5000", "192.168.1.1", "echo: " .. "hello")

    end
end)
t:start()
